def singleNumber(nums):
    """
    :type nums: List[int]
    :rtype: int
    """
    for i in range(len(nums)):
        temp = nums.pop(i)
        if temp not in nums:
            return temp
        else:
            nums.insert(i, temp)
    return


print(singleNumber([2, 2, 1]))  # 1
print(singleNumber([4, 1, 2, 1, 2]))  # 4
